<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            margin:0;
            padding:0;
        }
        body {
            width:100%;
            background: url("./tiankong.jpg");
            -webkit-background-size: 100% 100%;
            background-size:100% 100%;
            cursor: url(./shubiao.ico),auto;
        }
        #defen {
            position: absolute;
            top:10px;
            left:5px;
        }
        .sanbing {
            position: absolute;
            width: 32px;
            height: 56px;
            background:url(./sanbing.png) no-repeat top left;
            -webkit-background-size: 100% 100%;
            background-size:100% 100%;
        }
    </style>
</head>
<body>
<div id="defen">当前得分:0</div>
<!--<div style="position: absolute;top: 600px;width: 100%;height: 5px;background-color: #233412;"></div>-->
<audio src="./7203.mp3" style="display: none;"></audio>
<audio src="./bgc.mp3" style="display: none;" autoplay loop></audio>
</body>
<script>

    //产生一个伞兵;
    var gao,kuan,dixian;
    gao = document.body.clientHeight||document.documentElement.clientHeight;
    kuan = document.body.clientWidth||document.documentElement.clientWidth;
    gao = Math.floor(gao * 16 /17);
    kuan = Math.floor(kuan * 13 /15);
    document.body.style.height = gao + 'px';
    dixian = Math.floor(gao * 29 /30) - 50;
    console.log(kuan,gao,dixian);
   var defen = 0;
    var t=[];
    var jieguo = true;
    function creatsan(Yzhou,i) {
        //产生一个div
        var sanbing = document.createElement('div');
        sanbing.setAttribute('class','sanbing');
        sanbing.setAttribute('onclick','kill(this,'+i+')');
       // sanbing.innerHTML = '伞兵';
        document.body.appendChild(sanbing);
        sanbing.style.left = Yzhou + 'px';
        var shu = -56;
        t[i] = setInterval(function(){
            sanbing.style.top = shu++ + 'px';
            if(shu == dixian){
                shibai();
            }
        },10);
    }
    function kill(e,i){
       // console.log(e,i);
        document.getElementsByTagName('audio')[0].play();
        document.body.removeChild(e);
        clearInterval(t[i]);
        defen++;
        document.getElementById('defen').innerHTML = '当前得分:'+ defen;
    }
    //产生多个随机位置的伞兵
    function tiao(){
        var i = 0;
        function bb() {
            var leftX = Math.floor(50+Math.random()*(kuan-49));
            creatsan(leftX,i);
            i++;
        }
        return bb;
    }
    var tt = tiao();
   function aa() {
       tt();
           // console.log(500-defen)
       zt =  setTimeout(aa,500-defen);
    }

    //失败函数
    function shibai(){
        clearTimeout(zt);
        for(var i in t){
            clearInterval(t[i]);
        }
        alert('任务失败!');
    }
    aa();
    //外挂
    function waigua() {
    	var ssbb = document.getElementsByClassName('sanbing');
    	for (var i = 0; i < t.length ; i++) {
    		kill(ssbb[i],i);
    	}
    }

</script>
</html>